function Stack() {
    this._array = [];
}
Stack.prototype = {
    push: function(object) {
      this._array.push(object);
    },
    pop: function() {
        if (this.isEmpty()) {
            throw Stack.StackEmptyException;
        }
        return this._array.pop();
    },
    peek: function() {
        if (this.isEmpty()) {
            throw Stack.StackEmptyException;
        }
        return this._array[this._array.length - 1];
    },
    clear: function() {
      this._array = [];
    },
    isEmpty: function() {
       return this._array.length === 0;
    }
};
Stack.StackEmptyException = "stack is empty";